import { ACTION_TYPES } from 'utils/constant';
import { Get } from 'utils/handler';


export const getUserList = name => dispatch => {
    dispatch({
        type: ACTION_TYPES.USER_LIST_REQUEST
    })
    Get('/user/list', {
        data: {
            name
        }
    }).then(res => {
        if (res.reasonCode === 200) {
            dispatch({
                type: ACTION_TYPES.USER_LIST_SUCCESS,
                users: res.users
            })
        } else {
            dispatch({
                type: ACTION_TYPES.USER_LIST_FAIL
            })
        }
    }).catch(e => {
        dispatch({
            type: ACTION_TYPES.USER_LIST_FAIL
        })
    })
}